<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('休假管理')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list" id ='csList'>
                    <ul>
<!--                        <li>-->
<!--                            <label>项目名称：</label>&lt;!&ndash;  含有不同参数类型 &ndash;&gt;-->
<!--                            <select class="first form-control m-b col-sm-2" id="projectName" name="projectName">-->
<!--                                <option value="">所有</option>-->
<!--                            </select>-->
<!--                        </li>-->
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <label>姓名：</label>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <label>年份：</label>
                            <input type="text" name="year"/>
                        </li>
                        <li>
                            <label>年假时长（小时）</label>
                            <input type="text" name="yearHolTotal"/>
                        </li>
                        <!--<li>-->
                            <!--<label>时间：</label>-->
                            <!--<input type="text" class="form-control" placeholder="请选择时间(yyyyMM)" id="etldt" name="etldt" />-->
                        <!--</li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
<!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="hrm:sysHoliday:add">-->
<!--                <i class="fa fa-plus"></i> 添加-->
<!--            </a>-->
<!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="hrm:sysHoliday:edit">-->
<!--                <i class="fa fa-edit"></i> 修改-->
<!--            </a>-->
<!--            <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="hrm:sysHoliday:import">-->
<!--                <i class="fa fa-upload"></i> 导入明细-->
<!--            </a>-->
<!--            <a class="btn btn-warning" onclick="exportDetailExcel()" shiro:hasPermission="hrm:sysHoliday:detailExport">-->
<!--                <i class="fa fa-download"></i> 导出明细-->
<!--            </a>-->
            <a class="btn btn-warning" onclick="detailList()" shiro:hasPermission="hrm:sysHoliday:detailList">
                <i class="fa fa-download"></i> 明细展示
            </a>
            <a class="btn btn-info" onclick="calculate()" shiro:hasPermission="hrm:sysHoliday:calculateValue">
                <i class="fa fa-adn"></i> 刷新汇总数据
            </a>
            <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="hrm:sysHoliday:export">
                <i class="fa fa-download"></i> 导出汇总
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jquery-cxselect-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">

    var data = [[${csList}]];
    $('#csList').cxSelect({
        selects: ['first'],
        required: true,
        jsonValue: 'v',
        data: data
    });
    var prefix = ctx + "hrm/sysHoliday";
    var options;
    function query() {
        if(options!=null&&options!=undefined){
            var params = $("#bootstrap-table").bootstrapTable('getOptions');
            $("#bootstrap-table").bootstrapTable('refresh', params);
        }else{
            options = {
            url: prefix + "/list",
            importUrl: prefix + "/importData",
            exportUrl: prefix + "/export",
            importTemplateUrl: prefix + "/importTemplate",
            detailExportUrl:prefix + "/detailExport",
            uniqueId:"holidayUuid",
            modalName: "休假信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'holidayUuid',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'serialNum',
                    title: '序号',
                    visible: true
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'userName',
                    title: '员工名称'
                },
                {
                    field: 'year',
                    title: '年份'
                },
                {
                    field: 'yearHolTotal',
                    title: '年假时长(小时）'
                },
                {
                    field: 'month1',
                    title: '1月已休时长'
                },
                {
                    field: 'month2',
                    title: '2月已休时长'
                },
                {
                    field: 'month3',
                    title: '3月已休时长'
                },
                {
                    field: 'month4',
                    title: '4月已休时长'
                },
                {
                    field: 'month5',
                    title: '5月已休时长'
                },
                {
                    field: 'month6',
                    title: '6月已休时长'
                },
                {
                    field: 'month7',
                    title: '7月已休时长'
                },
                {
                    field: 'month8',
                    title: '8月已休时长'
                },
                {
                    field: 'month9',
                    title: '9月已休时长'
                },
                {
                    field: 'month10',
                    title: '10月已休时长'
                },
                {
                    field: 'month11',
                    title: '11月已休时长'
                },
                {
                    field: 'month12',
                    title: '12月已休时长'
                },
                {
                    field: 'yearHolDate',
                    title: '已休年假时长(小时）'
                },
                {
                    field: 'casuHolDate',
                    title: '已休事假时长(小时）'
                },
                {
                    field: 'sickHolDate',
                    title: '已休病假时长(小时）'
                }]
        };
        $.table.init(options);
        }
    }
    function calculate(){
        table.set();
        var url =  prefix + "/calculateValue";
        var data = { };
        $.operate.submit(url, "post", "json", data);
    }
    // function importExcel(){
    //     table.set();
    //     var url = prefix+"/importTemplate";
    //     var data = {"flag":"1"};
    //     $.operate.submit(url, "post", "json", data);
    // }
    // function importTotalExcel(){
    //     table.set();
    //     var url = prefix+"/importTemplate";
    //     var data = {"flag":"2"};
    //     $.operate.submit(url, "post", "json", data);
    // }
    // function importTemplate() {
    //     table.set();
    //     var flag = $('input[name="mx_flag"]:checked').val();
    //     alert(flag);
    //     $.get(table.options.importTemplateUrl+"?flag="+flag, function(result) {
    //         if (result.code == web_status.SUCCESS) {
    //             window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
    //         } else if (result.code == web_status.WARNING) {
    //             $.modal.alertWarning(result.msg)
    //         } else {
    //             $.modal.alertError(result.msg);
    //         }
    //     });
    // }
    function exportExcel(){
        var rows=$.table.selectColumns(table.options.uniqueId);
        var msg = "确定导出" + table.options.modalName + "吗？"
        if(rows.length!=0){
            msg = "确定导出勾选的"+rows.length+"条数据吗？"
        }
        $.modal.confirm(msg, function() {
            var params = $("#" + table.options.id).bootstrapTable('getOptions');
            var dataParam = $("#formId").serializeArray();
            dataParam.push({ "name": "orderByColumn", "value": params.sortName });
            dataParam.push({ "name": "isAsc", "value": params.sortOrder });
            if(rows.length!=0){
                dataParam.push({"name": "ids", "value": rows.join()});
            }
            $.modal.loading("正在导出数据，请稍后...");
            $.post(table.options.exportUrl, dataParam, function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }
    // function exportDetailExcel(){
    //     var rows=$.table.selectColumns(table.options.uniqueId);
    //     var msg = "确定导出全部个人明细吗？"
    //     if(rows.length!=0){
    //         msg = "确定导出勾选的"+rows.length+"条数据的个人明细吗？"
    //     }
    //     $.modal.confirm(msg, function() {
    //         var params = $("#" + table.options.id).bootstrapTable('getOptions');
    //         var dataParam = $("#formId").serializeArray();
    //         dataParam.push({ "name": "orderByColumn", "value": params.sortName });
    //         dataParam.push({ "name": "isAsc", "value": params.sortOrder });
    //         if(rows.length!=0){
    //             dataParam.push({"name": "ids", "value": rows.join()});
    //         }
    //         $.modal.loading("正在导出数据，请稍后...");
    //         $.post(table.options.detailExportUrl, dataParam, function(result) {
    //             if (result.code == web_status.SUCCESS) {
    //                 window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
    //             } else if (result.code == web_status.WARNING) {
    //                 $.modal.alertWarning(result.msg)
    //             } else {
    //                 $.modal.alertError(result.msg);
    //             }
    //             $.modal.closeLoading();
    //         });
    //     });
    // }
    function detailList() {
        $.modal.openTab("明细展示", prefix + "/detailList");
    }
</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs" shiro:hasPermission="hrm:sysHoliday:template"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>